/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.uoc.tdp.pac3.persistence.dao;

import edu.uoc.tdp.pac3.persistence.dao.impl.AreaDao;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import edu.uoc.tdp.pac3.domain.Area;
import java.sql.Date;
import org.junit.Ignore;
import static org.junit.Assert.*;

/**
 *
 * @author Gerard
 */
public class AreaDaoTestCase {
    
    private static IAreaDao dao;
    
    @BeforeClass
    public static void setUpClass() throws Exception {
        dao = new AreaDao();
    }

    @Test
    public void test_retrieve_data(){
        List<Area> list = dao.findAll();
        assertEquals(5, list.size());
    }
    
    @Test
    public void test_findById(){
        Area area = dao.findById(1);
        assertNotNull(area);
    }
    
    @Test
    public void test_insert(){
        Area area = new Area();
        area.setId(6);
        area.setName("JUNIT TEST");
        area.setCreationDate(new Date(2011,2, 2));
        assertTrue(dao.insert(area));
    }
    
    @Test
    public void test_update(){
        Area area = dao.findById(1);
        area.setName("JUNIT_TEST3");
        assertTrue(dao.update(area));
    }
    
    @Test
    public void test_delete(){
        Area area = dao.findById(6);
        assertNotNull(area);
        Boolean result = dao.delete(area);
        assertTrue(result);
    }
}
